package com.wanganui.douyin.properties;

import lombok.Getter;
import lombok.Setter;
import org.skyer.douyin.config.AgentConfiguration;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author xtwang
 * @date 2025/03/14 下午17:08
 */
@Setter
@Getter
@Component
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@ConfigurationProperties(prefix = "douyin")
public class DyConfigurationProperties {

    /**
     * 抖音Open API域名
     */
    private String domain;

    /**
     * 头条Open API域名
     */
    private String ttDomain;

    /**
     * 沙箱环境 API域名
     */
    private String sandboxDomain;

    /**
     * 是否开启沙箱环境
     */
    private Boolean sandbox = false;

    /**
     * 应用配置（可配置多个应用）
     */
    private List<AgentConfiguration> agents;

    /**
     * forest参数配置
     */
    private DyForestConfigurationProperties forest;

    /**
     * 应用配置类
     */
    private String agentSourceClass = "com.dyj.common.service.impl.PropertiesAgentConfigServiceImpl";

    /**
     * token配置类
     */
    private String tokenSourceClass = "com.dyj.common.service.impl.CacheAgentTokenServiceImpl";

    public String getTtDomain() {
        if (sandbox) {
            return sandboxDomain;
        }
        return ttDomain;
    }

    public String getDomain() {
        if (sandbox) {
            return sandboxDomain;
        }
        return domain;
    }
}
